<?php
	class Model_cruises extends CI_Model{
		protected $_table = "tbl_agecruise";
		protected $_cruises = "tbl_sheep";
		protected $_wcrui = "tbl_cruises";
		protected $_gallery = "tbl_gallerys";
		public function __construct(){
			parent::__construct();
			$this->load->database();
		}
		public function listcruis($userid){
			$this->db->select("sheep_id,sheep_name,sheep_status,agency_id,agency_name,cruises_id");
			$this->db->join($this->_cruises,"tbl_sheep.sheep_id = tbl_agecruise.cruises_id");
			$this->db->where($this->_cruises.".sheep_status",1);
			$this->db->where($this->_table.".agency_id",$userid);
			return $this->db->get($this->_table)->result_array();
		}
		public function getdata($id){
			$this->db->where("sheep_id",$id);
			return $this->db->get($this->_cruises)->row_array();
		}
		public function getgalery($id){
			$this->db->where("gallery_id",$id);
			return $this->db->get($this->_gallery)->row_array();
		}
		public function delgalery($id){
			$this->db->where("gallery_id",$id);
			$this->db->delete($this->_gallery);
		}
		public function addgal($data){
			$this->db->insert($this->_gallery,$data);
		}
		public function add($data){
			$this->db->insert($this->_wcrui,$data);
		}
		public function update($data,$id){
			$this->db->where("sheep_id",$id);
			$this->db->update($this->_cruises,$data);
		}
		public function gallery($id){
			$this->db->where("album_id",$id);
			return $this->db->get($this->_gallery)->result_array();
		}
	}